package Demo2;

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int len = in.nextInt();
        int[] nums = new int[len];
        for(int i = 0; i < len; i++) {
            nums[i] = in.nextInt();
        }
        int left = dfs(nums, 0);
        int right = dfs(nums, 1);
        System.out.print(Math.min(left, right));
    }
    public static int dfs(int[] nums, int pow) {
        if(pow >= nums.length) {
            return 0;
        }

        int left = dfs(nums, pow + 1);
        int right = dfs(nums, pow + 2);
        return left < right ? left + nums[pow] : right + nums[pow];
    }
}